#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char* longestPalindrome(char* s)
{
    // center diffusion utilizing the sym
    const int sl = strlen(s);
    if(sl<=1) return s;
    int i,j,idx=0;
    int res_l = 1;
    int res_i=0;// res start pos

    while(idx<sl-1)
    {
        i=j=idx;
        // 相同字符的处理
        while(s[j+1] == s[idx++])
        {
            if(++j >= sl) break;
        }
        while(i>0 && j<sl-1 && s[i-1] == s[j+1])
        {
            i--;j++;
        }
        if(j-i+1 > res_l)
        {
            res_l = j-i+1;
            res_i = i;
        }
    }
    char* res = (char*)malloc(sizeof(char)*(res_l+1));
    res[res_l] = 0;
    for(int id = 0;id<res_l;++id)
    {
        res[id] = s[res_i+id];
    }
    return res;
}

#define MAX 1000



/* 
dp way. too slow for this problem

char* longestPalindrome(char* s)
{
    int p[MAX][MAX]={0};
    const int sl = strlen(s);
    if (sl==1) return s;
    int l=1,i=0,j;
    int res_l = 1;
    int res_id[2]={0};
    for(l = 1;l<sl;++l)
    {
        for(i = 0;s[i+l];++i)
        {
            j = i+l;
            p[i][j] = (s[i]==s[j]) && (l<=2 || p[i+1][j-1]);
            if(p[i][j] && l+1>res_l)
            {
                res_l = l+1;
                res_id[0] = i; res_id[1] = j;
            }
        }
    }
    char* res = (char*)malloc(sizeof(char)*(res_l+1));
    res[res_l] = 0;
    for(int id = 0;id<res_l;++id)
    {
        res[id] = s[res_id[0]+id];
    }
    return res;
}
*/


int main(int argc, char const *argv[])
{
    char s[MAX];
    freopen("./medium/test.txt","r",stdin);
    scanf("%s",s);
    char* res = longestPalindrome(s);
    printf("%s",res);
    return 0;
}
